package com.wash.framework.utils;

import org.springframework.util.ClassUtils;

public abstract class StringUtils extends org.springframework.util.StringUtils
{
  public static boolean isEmpty(String string)
  {
    return (string == null) || (string.length() == 0);
  }

  public static String buildPathByBeanClass(Class beanClass, String[] frameworkPackagePrefixs, String[] actionPackageSuffixs, boolean caseSensitive)
  {
    String packageName = ClassUtils.getPackageName(beanClass);
    if (isEmpty(packageName)) {
      return "";
    }
    String actionPackageSuffix = "";
    for (String packageSuffix : actionPackageSuffixs) {
      if (packageName.endsWith(packageSuffix)) {
        actionPackageSuffix = packageSuffix;
        break;
      }
    }
    for (String frameworkPackagePrefix : frameworkPackagePrefixs) {
      if (packageName.startsWith(frameworkPackagePrefix)) {
        packageName = replace(packageName, frameworkPackagePrefix, "");
        break;
      }
    }
    packageName = replace(packageName, actionPackageSuffix, "");
    packageName = replace(packageName, ".", "/");
    return new StringBuilder().append(caseSensitive ? packageName : packageName.toLowerCase()).append("/").toString();
//    return new StringBuilder().append(caseSensitive ? packageName : packageName.toLowerCase()).toString();
  }

  public static boolean containsText(String str, String delimiter)
  {
    if (str.indexOf(delimiter) > -1) {
      return true;
    }
    return false;
  }

  public static String convertNumber(Long number)
  {
    return Long.toBinaryString(number.longValue());
  }
}